package com.qf.service.impl;


import com.qf.dao.CarDao;
import com.qf.pojo.Car;
import com.qf.pojo.resp.BaseResult;
import com.qf.service.CarService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class CarServiceImpl implements CarService {

  BaseResult baseResult = new BaseResult();

  @Resource
  CarDao carDao;

    @Override
    public BaseResult findAllCar() {
        List<Car>  car = carDao.findAllCar();
        baseResult.setCode(1);
        baseResult.setInfo("成功");
        baseResult.setData(car);
        return baseResult;
    }

    @Override
    public BaseResult addCar(Car car) {
        Integer integer = carDao.addCar(car);
        baseResult.setCode(integer);
        baseResult.setInfo("成功");
        baseResult.setData(car);
        return baseResult;
    }

    @Override
    public BaseResult findCarById(Integer p_id) {
        Car car = carDao.findCarById(p_id);
        baseResult.setCode(1);
        baseResult.setInfo("成功");
        baseResult.setData(car);
        return baseResult;
    }
}
